// entities/post.entity.ts
import { Column, Entity, ManyToMany, ManyToOne, PrimaryColumn, PrimaryGeneratedColumn } from "typeorm";
import { User } from "./user.entity";

class userCheck {
    id: number;
    account: string
}

@Entity("check")
export class Check {
    @PrimaryGeneratedColumn()
    id: number;

    @Column()
    time: Date;

    @Column()
    status: string;

    // 在 @ManyToOne 一侧，即在外键拥有者一侧，设置 onDelete，就可以使用外键的级联功能，这里设置级联删除，当删除 user 时，user 的所有 post 会被级联删除
    @ManyToOne(type => User, user => user.checks, {
        cascade: true,// 自动保存相关对象
        onDelete: 'CASCADE'
    })
    user: userCheck;
}